import React, { FC } from "react";
import { Typography } from "antd";
import QuestionTitleDefault, { QuestionTitleType } from "./interface";

const { Title } = Typography;

const QuestionTitle: FC<QuestionTitleType> = (props: QuestionTitleType) => {
  const {
    text = "",
    level = 1,
    isCenter = false,
  } = { ...QuestionTitleDefault, ...props };

  // 自定义字体大小
  function getFontSize(level: number) {
    switch (level) {
      case 1:
        return "24px";
      case 2:
        return "22px";
      case 3:
        return "20px";
      case 4:
        return "18px";
      case 5:
        return "16px";
    }
  }
  return (
    <Title
      level={level}
      style={{
        textAlign: isCenter ? "center" : "start",
        fontSize: getFontSize(level),
        height: '30px',
        lineHeight : '30px',
        margin : '0px'
      }}
    >
      {text}
    </Title>
  );
};

export default QuestionTitle;
